package com.thingsgrid.basicInterface.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.devloper.joker.mybatis.plus.query.core.QuerySupport;
import com.thingsgrid.basicInterface.entity.BasicInterface;
import com.thingsgrid.basicInterface.vo.BasicInterfaceVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *  Mapper 接口
 *
 * @author BladeX
 * @since 2019-08-10
 */
@QuerySupport
public interface BasicInterfaceMapper extends BaseMapper<BasicInterface> {

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param basicInterface
	 * @return
	 */
	List<BasicInterfaceVo> selectBasicInterfacePage(IPage page, BasicInterfaceVo basicInterface);


	@QuerySupport
	@Select("SELECT interface.*,intefaceType.type_name from blade_basic_interface as interface  LEFT JOIN blade_basic_interface_type as intefaceType ON interface.type_id =  intefaceType.id ")
	 List<BasicInterfaceVo> findApiAndTypeNamePage(IPage<BasicInterfaceVo> page,@Param(Constants.WRAPPER) Wrapper<BasicInterfaceVo> wrapper);



	// 根据权限包查询接口
	@QuerySupport
	@Select("SELECT interface.* from blade_basic_interface as interface  LEFT JOIN  blade_api_type_relation as apiTypeRe  ON interface.api_id =  apiTypeRe.api_id LEFT JOIN blade_basic_interface_type as intefaceType ON intefaceType.id = apiTypeRe.type_id  where intefaceType.id = #{id}")
	List<BasicInterface> findApiByPackage(Long id);


}

